<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>input 检验函数 | 海内存知已，天涯若比邻</title><meta name="keywords" content="web,前端"><meta name="author" content="mowei"><meta name="copyright" content="mowei"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210">
<meta property="og:type" content="article">
<meta property="og:title" content="input 检验函数">
<meta property="og:url" content="https://gitee.com/momomomowei/blog/utils/input%20%E6%A3%80%E9%AA%8C%E5%87%BD%E6%95%B0%20vue3/index.html">
<meta property="og:site_name" content="海内存知已，天涯若比邻">
<meta property="og:description" content="12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/momomomowei/images/utils.png">
<meta property="article:published_time" content="2024-01-18T06:06:43.000Z">
<meta property="article:modified_time" content="2024-04-21T07:24:14.411Z">
<meta property="article:author" content="mowei">
<meta property="article:tag" content="web">
<meta property="article:tag" content="前端">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/momomomowei/images/utils.png"><link rel="shortcut icon" href="/media/favicon.png"><link rel="canonical" href="https://gitee.com/momomomowei/blog/utils/input%20%E6%A3%80%E9%AA%8C%E5%87%BD%E6%95%B0%20vue3/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: true,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'input 检验函数',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2024-04-21 15:24:14'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const fontSizeVal = saveToLocal.get('global-font-size')
    if (fontSizeVal !== undefined) {
      document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
    }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    document.addEventListener('pjax:complete', detectApple)})(window)</script><meta name="generator" content="Hexo 5.4.2"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="/media/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">41</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">29</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 目录</span><i class="fas fa-chevron-down expand hide"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/images/utils.png')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">海内存知已，天涯若比邻</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 目录</span><i class="fas fa-chevron-down expand hide"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">input 检验函数</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-01-18T06:06:43.000Z" title="发表于 2024-01-18 14:06:43">2024-01-18</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-04-21T07:24:14.411Z" title="更新于 2024-04-21 15:24:14">2024-04-21</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E5%B7%A5%E5%85%B7%E5%87%BD%E6%95%B0/">工具函数</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">6.4k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>32分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="input 检验函数"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 验证百分比（不可以小数）</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回处理后的字符串</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyNumberPercentage</span>(<span class="params">val: <span class="built_in">string</span></span>): <span class="built_in">string</span> &#123;</span><br><span class="line">    <span class="comment">// 匹配空格</span></span><br><span class="line">    <span class="keyword">let</span> v = val.<span class="title function_">replace</span>(<span class="regexp">/(^\s*)|(\s*$)/g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 只能是数字和小数点，不能是其他输入</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/[^\d]/g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 不能以0开始</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/^0/g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 数字超过100，赋值成最大值100</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/^[1-9]\d\d&#123;1,3&#125;$/</span>, <span class="string">&#x27;100&#x27;</span>);</span><br><span class="line">    <span class="comment">// 返回结果</span></span><br><span class="line">    <span class="keyword">return</span> v;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 验证百分比（可以小数）</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回处理后的字符串</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyNumberPercentageFloat</span>(<span class="params">val: <span class="built_in">string</span></span>): <span class="built_in">string</span> &#123;</span><br><span class="line">    <span class="keyword">let</span> v = <span class="title function_">verifyNumberIntegerAndFloat</span>(val);</span><br><span class="line">    <span class="comment">// 数字超过100，赋值成最大值100</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/^[1-9]\d\d&#123;1,3&#125;$/</span>, <span class="string">&#x27;100&#x27;</span>);</span><br><span class="line">    <span class="comment">// 超过100之后不给再输入值</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/^100\.$/</span>, <span class="string">&#x27;100&#x27;</span>);</span><br><span class="line">    <span class="comment">// 返回结果</span></span><br><span class="line">    <span class="keyword">return</span> v;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 小数或整数(不可以负数)</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回处理后的字符串</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyNumberIntegerAndFloat</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// 匹配空格</span></span><br><span class="line">    <span class="keyword">let</span> v = val.<span class="title function_">replace</span>(<span class="regexp">/(^\s*)|(\s*$)/g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 只能是数字和小数点，不能是其他输入</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/[^\d.]/g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 以0开始只能输入一个</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/^0&#123;2&#125;$/g</span>, <span class="string">&#x27;0&#x27;</span>);</span><br><span class="line">    <span class="comment">// 保证第一位只能是数字，不能是点</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/^\./g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 小数只能出现1位</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="string">&#x27;.&#x27;</span>, <span class="string">&#x27;$#$&#x27;</span>).<span class="title function_">replace</span>(<span class="regexp">/\./g</span>, <span class="string">&#x27;&#x27;</span>).<span class="title function_">replace</span>(<span class="string">&#x27;$#$&#x27;</span>, <span class="string">&#x27;.&#x27;</span>);</span><br><span class="line">    <span class="comment">// 小数点后面保留2位</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/^(\-)*(\d+)\.(\d\d).*$/</span>, <span class="string">&#x27;$1$2.$3&#x27;</span>);</span><br><span class="line">    <span class="comment">// 返回结果</span></span><br><span class="line">    <span class="keyword">return</span> v;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 正整数验证</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回处理后的字符串</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifiyNumberInteger</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// 匹配空格</span></span><br><span class="line">    <span class="keyword">let</span> v = val.<span class="title function_">replace</span>(<span class="regexp">/(^\s*)|(\s*$)/g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 去掉 &#x27;.&#x27; , 防止贴贴的时候出现问题 如 0.1.12.12</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/[\.]*/g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 去掉以 0 开始后面的数, 防止贴贴的时候出现问题 如 00121323</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/(^0[\d]*)$/g</span>, <span class="string">&#x27;0&#x27;</span>);</span><br><span class="line">    <span class="comment">// 首位是0,只能出现一次</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/^0\d$/g</span>, <span class="string">&#x27;0&#x27;</span>);</span><br><span class="line">    <span class="comment">// 只匹配数字</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/[^\d]/g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 返回结果</span></span><br><span class="line">    <span class="keyword">return</span> v;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 去掉中文及空格</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回处理后的字符串</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyCnAndSpace</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// 匹配中文与空格</span></span><br><span class="line">    <span class="keyword">let</span> v = val.<span class="title function_">replace</span>(<span class="regexp">/[\u4e00-\u9fa5\s]+/g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 匹配空格</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/(^\s*)|(\s*$)/g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 返回结果</span></span><br><span class="line">    <span class="keyword">return</span> v;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 去掉英文及空格</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回处理后的字符串</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyEnAndSpace</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// 匹配英文与空格</span></span><br><span class="line">    <span class="keyword">let</span> v = val.<span class="title function_">replace</span>(<span class="regexp">/[a-zA-Z]+/g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 匹配空格</span></span><br><span class="line">    v = v.<span class="title function_">replace</span>(<span class="regexp">/(^\s*)|(\s*$)/g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 返回结果</span></span><br><span class="line">    <span class="keyword">return</span> v;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 禁止输入空格</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回处理后的字符串</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyAndSpace</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// 匹配空格</span></span><br><span class="line">    <span class="keyword">let</span> v = val.<span class="title function_">replace</span>(<span class="regexp">/(^\s*)|(\s*$)/g</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="comment">// 返回结果</span></span><br><span class="line">    <span class="keyword">return</span> v;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 金额用 `,` 区分开</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回处理后的字符串</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyNumberComma</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// 调用小数或整数(不可以负数)方法</span></span><br><span class="line">    <span class="keyword">let</span> <span class="attr">v</span>: <span class="built_in">any</span> = <span class="title function_">verifyNumberIntegerAndFloat</span>(val);</span><br><span class="line">    <span class="comment">// 字符串转成数组</span></span><br><span class="line">    v = v.<span class="title function_">toString</span>().<span class="title function_">split</span>(<span class="string">&#x27;.&#x27;</span>);</span><br><span class="line">    <span class="comment">// \B 匹配非单词边界，两边都是单词字符或者两边都是非单词字符</span></span><br><span class="line">    v[<span class="number">0</span>] = v[<span class="number">0</span>].<span class="title function_">replace</span>(<span class="regexp">/\B(?=(\d&#123;3&#125;)+(?!\d))/g</span>, <span class="string">&#x27;,&#x27;</span>);</span><br><span class="line">    <span class="comment">// 数组转字符串</span></span><br><span class="line">    v = v.<span class="title function_">join</span>(<span class="string">&#x27;.&#x27;</span>);</span><br><span class="line">    <span class="comment">// 返回结果</span></span><br><span class="line">    <span class="keyword">return</span> v;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 匹配文字变色（搜索时）</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> text 要处理的字符串值</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> color 搜索到时字体高亮颜色</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回处理后的字符串</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyTextColor</span>(<span class="params">val: <span class="built_in">string</span>, text = <span class="string">&#x27;&#x27;</span>, color = <span class="string">&#x27;red&#x27;</span></span>) &#123;</span><br><span class="line">    <span class="comment">// 返回内容，添加颜色</span></span><br><span class="line">    <span class="keyword">let</span> v = text.<span class="title function_">replace</span>(<span class="keyword">new</span> <span class="title class_">RegExp</span>(val, <span class="string">&#x27;gi&#x27;</span>), <span class="string">`&lt;span style=&#x27;color: <span class="subst">$&#123;color&#125;</span>&#x27;&gt;<span class="subst">$&#123;val&#125;</span>&lt;/span&gt;`</span>);</span><br><span class="line">    <span class="comment">// 返回结果</span></span><br><span class="line">    <span class="keyword">return</span> v;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 数字转中文大写</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> unit 默认：仟佰拾亿仟佰拾万仟佰拾元角分</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回处理后的字符串</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyNumberCnUppercase</span>(<span class="params">val: <span class="built_in">any</span>, unit = <span class="string">&#x27;仟佰拾亿仟佰拾万仟佰拾元角分&#x27;</span>, v = <span class="string">&#x27;&#x27;</span></span>) &#123;</span><br><span class="line">    <span class="comment">// 当前内容字符串添加 2个0，为什么??</span></span><br><span class="line">    val += <span class="string">&#x27;00&#x27;</span>;</span><br><span class="line">    <span class="comment">// 返回某个指定的字符串值在字符串中首次出现的位置，没有出现，则该方法返回 -1</span></span><br><span class="line">    <span class="keyword">let</span> lookup = val.<span class="title function_">indexOf</span>(<span class="string">&#x27;.&#x27;</span>);</span><br><span class="line">    <span class="comment">// substring：不包含结束下标内容，substr：包含结束下标内容</span></span><br><span class="line">    <span class="keyword">if</span> (lookup &gt;= <span class="number">0</span>) val = val.<span class="title function_">substring</span>(<span class="number">0</span>, lookup) + val.<span class="title function_">substr</span>(lookup + <span class="number">1</span>, <span class="number">2</span>);</span><br><span class="line">    <span class="comment">// 根据内容 val 的长度，截取返回对应大写</span></span><br><span class="line">    unit = unit.<span class="title function_">substr</span>(unit.<span class="property">length</span> - val.<span class="property">length</span>);</span><br><span class="line">    <span class="comment">// 循环截取拼接大写</span></span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; val.<span class="property">length</span>; i++) &#123;</span><br><span class="line">        v += <span class="string">&#x27;零壹贰叁肆伍陆柒捌玖&#x27;</span>.<span class="title function_">substr</span>(val.<span class="title function_">substr</span>(i, <span class="number">1</span>), <span class="number">1</span>) + unit.<span class="title function_">substr</span>(i, <span class="number">1</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 正则处理</span></span><br><span class="line">    v = v</span><br><span class="line">        .<span class="title function_">replace</span>(<span class="regexp">/零角零分$/</span>, <span class="string">&#x27;整&#x27;</span>)</span><br><span class="line">        .<span class="title function_">replace</span>(<span class="regexp">/零[仟佰拾]/g</span>, <span class="string">&#x27;零&#x27;</span>)</span><br><span class="line">        .<span class="title function_">replace</span>(<span class="regexp">/零&#123;2,&#125;/g</span>, <span class="string">&#x27;零&#x27;</span>)</span><br><span class="line">        .<span class="title function_">replace</span>(<span class="regexp">/零([亿|万])/g</span>, <span class="string">&#x27;$1&#x27;</span>)</span><br><span class="line">        .<span class="title function_">replace</span>(<span class="regexp">/零+元/</span>, <span class="string">&#x27;元&#x27;</span>)</span><br><span class="line">        .<span class="title function_">replace</span>(<span class="regexp">/亿零&#123;0,3&#125;万/</span>, <span class="string">&#x27;亿&#x27;</span>)</span><br><span class="line">        .<span class="title function_">replace</span>(<span class="regexp">/^元/</span>, <span class="string">&#x27;零元&#x27;</span>);</span><br><span class="line">    <span class="comment">// 返回结果</span></span><br><span class="line">    <span class="keyword">return</span> v;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 手机号码</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回 true: 手机号码正确</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyPhone</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// false: 手机号码不正确</span></span><br><span class="line">    <span class="keyword">if</span> (!<span class="regexp">/^((12[0-9])|(13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0|1,5-9]))\d&#123;8&#125;$/</span>.<span class="title function_">test</span>(val)) <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    <span class="comment">// true: 手机号码正确</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 国内电话号码</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回 true: 国内电话号码正确</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyTelPhone</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// false: 国内电话号码不正确</span></span><br><span class="line">    <span class="keyword">if</span> (!<span class="regexp">/\d&#123;3&#125;-\d&#123;8&#125;|\d&#123;4&#125;-\d&#123;7&#125;/</span>.<span class="title function_">test</span>(val)) <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    <span class="comment">// true: 国内电话号码正确</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 登录账号 (字母开头，允许5-16字节，允许字母数字下划线)</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回 true: 登录账号正确</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyAccount</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// false: 登录账号不正确</span></span><br><span class="line">    <span class="keyword">if</span> (!<span class="regexp">/^[a-zA-Z][a-zA-Z0-9_]&#123;4,15&#125;$/</span>.<span class="title function_">test</span>(val)) <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    <span class="comment">// true: 登录账号正确</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 密码 (以字母开头，长度在6~16之间，只能包含字母、数字和下划线)</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回 true: 密码正确</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyPassword</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// false: 密码不正确</span></span><br><span class="line">    <span class="keyword">if</span> (!<span class="regexp">/^[a-zA-Z]\w&#123;5,15&#125;$/</span>.<span class="title function_">test</span>(val)) <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    <span class="comment">// true: 密码正确</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 强密码 (字母+数字+特殊字符，长度在6-16之间)</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回 true: 强密码正确</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyPasswordPowerful</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// false: 强密码不正确</span></span><br><span class="line">    <span class="keyword">if</span> (!<span class="regexp">/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&amp;\.*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&amp;\.*]+$)(?![\d!@#$%^&amp;\.*]+$)[a-zA-Z\d!@#$%^&amp;\.*]&#123;6,16&#125;$/</span>.<span class="title function_">test</span>(val))</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    <span class="comment">// true: 强密码正确</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 密码强度</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span> 弱：纯数字，纯字母，纯特殊字符</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span> 中：字母+数字，字母+特殊字符，数字+特殊字符</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span> 强：字母+数字+特殊字符</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回处理后的字符串：弱、中、强</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyPasswordStrength</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="keyword">let</span> v = <span class="string">&#x27;&#x27;</span>;</span><br><span class="line">    <span class="comment">// 弱：纯数字，纯字母，纯特殊字符</span></span><br><span class="line">    <span class="keyword">if</span> (<span class="regexp">/^(?:\d+|[a-zA-Z]+|[!@#$%^&amp;\.*]+)&#123;6,16&#125;$/</span>.<span class="title function_">test</span>(val)) v = <span class="string">&#x27;弱&#x27;</span>;</span><br><span class="line">    <span class="comment">// 中：字母+数字，字母+特殊字符，数字+特殊字符</span></span><br><span class="line">    <span class="keyword">if</span> (<span class="regexp">/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&amp;\.*]+$)[a-zA-Z\d!@#$%^&amp;\.*]&#123;6,16&#125;$/</span>.<span class="title function_">test</span>(val)) v = <span class="string">&#x27;中&#x27;</span>;</span><br><span class="line">    <span class="comment">// 强：字母+数字+特殊字符</span></span><br><span class="line">    <span class="keyword">if</span> (<span class="regexp">/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&amp;\.*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&amp;\.*]+$)(?![\d!@#$%^&amp;\.*]+$)[a-zA-Z\d!@#$%^&amp;\.*]&#123;6,16&#125;$/</span>.<span class="title function_">test</span>(val))</span><br><span class="line">        v = <span class="string">&#x27;强&#x27;</span>;</span><br><span class="line">    <span class="comment">// 返回结果</span></span><br><span class="line">    <span class="keyword">return</span> v;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * IP地址</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回 true: IP地址正确</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyIPAddress</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// false: IP地址不正确</span></span><br><span class="line">    <span class="keyword">if</span> (</span><br><span class="line">        !<span class="regexp">/^(\d&#123;1,2&#125;|1\d\d|2[0-4]\d|25[0-5])\.(\d&#123;1,2&#125;|1\d\d|2[0-4]\d|25[0-5])\.(\d&#123;1,2&#125;|1\d\d|2[0-4]\d|25[0-5])\.(\d&#123;1,2&#125;|1\d\d|2[0-4]\d|25[0-5])$/</span>.<span class="title function_">test</span>(</span><br><span class="line">            val</span><br><span class="line">        )</span><br><span class="line">    )</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    <span class="comment">// true: IP地址正确</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 邮箱</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回 true: 邮箱正确</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyEmail</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// false: 邮箱不正确</span></span><br><span class="line">    <span class="keyword">if</span> (</span><br><span class="line">        !<span class="regexp">/^(([^&lt;&gt;()\[\]\\.,;:\s@&quot;]+(\.[^&lt;&gt;()\[\]\\.,;:\s@&quot;]+)*)|(&quot;.+&quot;))@((\[[0-9]&#123;1,3&#125;\.[0-9]&#123;1,3&#125;\.[0-9]&#123;1,3&#125;\.[0-9]&#123;1,3&#125;\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]&#123;2,&#125;))$/</span>.<span class="title function_">test</span>(</span><br><span class="line">            val</span><br><span class="line">        )</span><br><span class="line">    )</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    <span class="comment">// true: 邮箱正确</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 身份证</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回 true: 身份证正确</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyIdCard</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// false: 身份证不正确</span></span><br><span class="line">    <span class="keyword">if</span> (!<span class="regexp">/^[1-9]\d&#123;5&#125;(18|19|20)\d&#123;2&#125;((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d&#123;3&#125;[0-9Xx]$/</span>.<span class="title function_">test</span>(val)) <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    <span class="comment">// true: 身份证正确</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 姓名</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回 true: 姓名正确</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyFullName</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// false: 姓名不正确</span></span><br><span class="line">    <span class="keyword">if</span> (!<span class="regexp">/^[\u4e00-\u9fa5]&#123;1,6&#125;(·[\u4e00-\u9fa5]&#123;1,6&#125;)&#123;0,2&#125;$/</span>.<span class="title function_">test</span>(val)) <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    <span class="comment">// true: 姓名正确</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 邮政编码</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回 true: 邮政编码正确</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyPostalCode</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// false: 邮政编码不正确</span></span><br><span class="line">    <span class="keyword">if</span> (!<span class="regexp">/^[1-9][0-9]&#123;5&#125;$/</span>.<span class="title function_">test</span>(val)) <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    <span class="comment">// true: 邮政编码正确</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * url 处理</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回 true: url 正确</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyUrl</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// false: url不正确</span></span><br><span class="line">    <span class="keyword">if</span> (</span><br><span class="line">        !<span class="regexp">/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d&#123;1,3&#125;)&#123;3&#125;)(?!(?:169\.254|192\.168)(?:\.\d&#123;1,3&#125;)&#123;2&#125;)(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d&#123;1,3&#125;)&#123;2&#125;)(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d&#123;1,2&#125;|2[0-4]\d|25[0-5]))&#123;2&#125;(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]&#123;2,&#125;)).?)(?::\d&#123;2,5&#125;)?(?:[/?#]\S*)?$/i</span>.<span class="title function_">test</span>(</span><br><span class="line">            val</span><br><span class="line">        )</span><br><span class="line">    )</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    <span class="comment">// true: url正确</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 车牌号</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> val 当前值字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns</span> 返回 true：车牌号正确</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">verifyCarNum</span>(<span class="params">val: <span class="built_in">string</span></span>) &#123;</span><br><span class="line">    <span class="comment">// false: 车牌号不正确</span></span><br><span class="line">    <span class="keyword">if</span> (</span><br><span class="line">        !<span class="regexp">/^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]&#123;5&#125;[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]&#123;4&#125;)))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]&#123;4&#125;[A-HJ-NP-Z0-9挂学警港澳使领]))$/</span>.<span class="title function_">test</span>(</span><br><span class="line">            val</span><br><span class="line">        )</span><br><span class="line">    )</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    <span class="comment">// true：车牌号正确</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br><span class="line">452</span><br><span class="line">453</span><br><span class="line">454</span><br><span class="line">455</span><br><span class="line">456</span><br><span class="line">457</span><br><span class="line">458</span><br><span class="line">459</span><br><span class="line">460</span><br><span class="line">461</span><br><span class="line">462</span><br><span class="line">463</span><br><span class="line">464</span><br><span class="line">465</span><br><span class="line">466</span><br><span class="line">467</span><br><span class="line">468</span><br><span class="line">469</span><br><span class="line">470</span><br><span class="line">471</span><br><span class="line">472</span><br><span class="line">473</span><br><span class="line">474</span><br><span class="line">475</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">    &lt;div class=&quot;layout-pd&quot;&gt;</span><br><span class="line">        &lt;el-card shadow=&quot;hover&quot; header=&quot;正则验证（一些项目中常用的正则）&quot;&gt;</span><br><span class="line">            &lt;el-form :model=&quot;state.ruleForm&quot; :rules=&quot;state.rules&quot; class=&quot;tools-warp-form&quot; size=&quot;default&quot; label-position=&quot;top&quot;&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;验证百分比（不可以小数）:&quot; prop=&quot;a22&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;验证可以输入大于0小于100的数字&lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a22&quot; @input=&quot;onVerifyNumberPercentage($event)&quot; placeholder=&quot;请输入数字进行测试&quot;&gt;</span><br><span class="line">                            &lt;template #append&gt; % &lt;/template&gt;</span><br><span class="line">                        &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;验证百分比（可以小数）:&quot; prop=&quot;a23&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;验证可以输入大于0小于100的数字&lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a23&quot; @input=&quot;onVerifyNumberPercentageFloat($event)&quot; placeholder=&quot;请输入数字进行测试&quot;&gt;</span><br><span class="line">                            &lt;template #append&gt; % &lt;/template&gt;</span><br><span class="line">                        &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;小数或整数:&quot; prop=&quot;a1&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证可以输入小数或整数，0 开始， . 只能出现一次，保留小数点后保留2位小数。(负数时，模拟拼接负号给后台)。</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a1&quot; @input=&quot;onVerifyNumberIntegerAndFloat($event)&quot; placeholder=&quot;请输入小数或整数进行测试&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;正整数:&quot; prop=&quot;a2&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;验证只可以输入正整数，0 开始后面将不可以输入。&lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a2&quot; @input=&quot;onVerifiyNumberInteger($event)&quot; placeholder=&quot;请输入整数进行测试&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;去掉中文及空格:&quot; prop=&quot;a3&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;验证不可以输入空格与中文。&lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a3&quot; @input=&quot;onVerifyCnAndSpace($event)&quot; placeholder=&quot;请输入内容进行测试&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;去掉英文及空格:&quot; prop=&quot;a4&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;验证不可以输入空格与英文。&lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a4&quot; @input=&quot;onVerifyEnAndSpace($event)&quot; placeholder=&quot;请输入内容进行测试&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;禁止输入空格:&quot; prop=&quot;a5&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;验证不可以输入空格。&lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a5&quot; @input=&quot;onVerifyAndSpace($event)&quot; placeholder=&quot;请输入内容进行测试&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;金额用 `,` 区分开:&quot; prop=&quot;a6&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;金额添加 `,` 进行区分，便于阅读。&#123;&#123; state.ruleForm.a6 &#125;&#125;&lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a6&quot; @input=&quot;onVerifyNumberComma($event)&quot; placeholder=&quot;请输入金额进行测试&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;匹配文字变色（搜索时）:&quot; prop=&quot;a7&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;示例：&lt;span v-html=&quot;state.text&quot;&gt;&lt;/span&gt;&lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a7&quot; @input=&quot;onVerifyTextColor($event)&quot; placeholder=&quot;请输入示例中的部分文字&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;数字转中文大写:&quot; prop=&quot;a8&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证数字转成中文的大写。&lt;span class=&quot;tools-warp-form-msg-red&quot;&gt;&#123;&#123; state.cnText &#125;&#125;&lt;/span&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a8&quot; @input=&quot;onVerifyNumberCnUppercase($event)&quot; placeholder=&quot;请输入金额进行测试&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;手机号码:&quot; prop=&quot;a9&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证手机号码 (true: 正确，false: 不正确)。&lt;span class=&quot;tools-warp-form-msg-red&quot;&gt;&#123;&#123; state.phone &#125;&#125;&lt;/span&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a9&quot; @input=&quot;onVerifyPhone($event)&quot; placeholder=&quot;请输入手机号进行测试&quot; maxlength=&quot;11&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;国内电话号码:&quot; prop=&quot;a10&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证国内电话号码 (true: 正确，false: 不正确)。&lt;span class=&quot;tools-warp-form-msg-red&quot;&gt;&#123;&#123; state.telePhone &#125;&#125;&lt;/span&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a10&quot; @input=&quot;onVerifyTelPhone($event)&quot; placeholder=&quot;请输入国内电话号码进行测试&quot; maxlength=&quot;12&quot;&gt;</span><br><span class="line">                        &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;登录账号:&quot; prop=&quot;a11&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证登录账号是否正确。字母开头，允许5-16字节，允许字母数字下划线 (true: 正确，false: 不正确)。&lt;span class=&quot;tools-warp-form-msg-red&quot;&gt;&#123;&#123;</span><br><span class="line">                            state.account</span><br><span class="line">                        &#125;&#125;&lt;/span&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a11&quot; @input=&quot;onVerifyAccount($event)&quot; placeholder=&quot;请输入账号进行测试&quot; maxlength=&quot;16&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;密码:&quot; prop=&quot;a12&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证密码是否正确。以字母开头，长度在6~16之间，只能包含字母、数字和下划线 (true: 正确，false: 不正确)。&lt;span</span><br><span class="line">                            class=&quot;tools-warp-form-msg-red&quot;</span><br><span class="line">                            &gt;&#123;&#123; state.password &#125;&#125;&lt;/span</span><br><span class="line">                        &gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a12&quot; @input=&quot;onVerifyPassword($event)&quot; placeholder=&quot;请输入密码进行测试&quot; maxlength=&quot;16&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;强密码:&quot; prop=&quot;a13&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证强密码是否正确。字母+数字+特殊字符，长度在6-16之间 (true: 正确，false: 不正确)。&lt;span class=&quot;tools-warp-form-msg-red&quot;&gt;&#123;&#123;</span><br><span class="line">                            state.passwordPowerful</span><br><span class="line">                        &#125;&#125;&lt;/span&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a13&quot; @input=&quot;onVerifyPasswordPowerful($event)&quot; placeholder=&quot;请输入密码进行测试&quot; maxlength=&quot;16&quot;&gt;</span><br><span class="line">                        &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;密码强度:&quot; prop=&quot;a14&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证密码强度。返回 强、中、弱。(弱：纯数字，纯字母，纯特殊字符，中：字母+数字，字母+特殊字符，数字+特殊字符，强：字母+数字+特殊字符)&lt;span</span><br><span class="line">                            class=&quot;tools-warp-form-msg-red&quot;</span><br><span class="line">                            &gt;&#123;&#123; state.passwordStrength &#125;&#125;&lt;/span</span><br><span class="line">                        &gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a14&quot; @input=&quot;onVerifyPasswordStrength($event)&quot; placeholder=&quot;请输入密码进行测试&quot; maxlength=&quot;16&quot;&gt;</span><br><span class="line">                        &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;IP地址:&quot; prop=&quot;a15&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证IP地址是否正确。(true: 正确，false: 不正确)。&lt;span class=&quot;tools-warp-form-msg-red&quot;&gt;&#123;&#123; state.iPAddress &#125;&#125;&lt;/span&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a15&quot; @input=&quot;onVerifyIPAddress($event)&quot; placeholder=&quot;请输入IP地址进行测试&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;邮箱:&quot; prop=&quot;a16&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证邮箱是否正确。(true: 正确，false:不正确)。&lt;span class=&quot;tools-warp-form-msg-red&quot;&gt;&#123;&#123; state.email &#125;&#125;&lt;/span&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a16&quot; @input=&quot;onVerifyEmail($event)&quot; placeholder=&quot;请输入邮箱进行测试&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;身份证:&quot; prop=&quot;a17&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证身份证是否正确。(true: 正确，false:不正确)。&lt;span class=&quot;tools-warp-form-msg-red&quot;&gt;&#123;&#123; state.idCard &#125;&#125;&lt;/span&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a17&quot; @input=&quot;onVerifyIDCard($event)&quot; placeholder=&quot;请输入身份证进行测试&quot; maxlength=&quot;18&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;姓名:&quot; prop=&quot;a18&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证姓名是否正确，包括少数民族名字。(true: 正确，false:不正确)。&lt;span class=&quot;tools-warp-form-msg-red&quot;&gt;&#123;&#123; state.fullName &#125;&#125;&lt;/span&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a18&quot; @input=&quot;onVerifyFullName($event)&quot; placeholder=&quot;请输入姓名进行测试&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;邮政编码:&quot; prop=&quot;a19&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证邮政编码是否正确，不能以 0 开始。(true: 正确，false:不正确)。&lt;span class=&quot;tools-warp-form-msg-red&quot;&gt;&#123;&#123; state.postalCode &#125;&#125;&lt;/span&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a19&quot; @input=&quot;onVerifyPostalCode($event)&quot; placeholder=&quot;请输入邮政编码进行测试&quot; maxlength=&quot;6&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;url:&quot; prop=&quot;a20&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证url是否正确。(true: 正确，false:不正确)。&lt;span class=&quot;tools-warp-form-msg-red&quot;&gt;&#123;&#123; state.url &#125;&#125;&lt;/span&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a20&quot; @input=&quot;onVerifyUrl($event)&quot; placeholder=&quot;请输入内容进行测试&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">                &lt;el-form-item label=&quot;车牌号:&quot; prop=&quot;a21&quot; class=&quot;mt20&quot;&gt;</span><br><span class="line">                    &lt;div class=&quot;tools-warp-form-msg&quot;&gt;</span><br><span class="line">                        验证车牌号是否正确。(true: 正确，false:不正确)。&lt;span class=&quot;tools-warp-form-msg-red&quot;&gt;&#123;&#123; state.carNum &#125;&#125;&lt;/span&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div&gt;</span><br><span class="line">                        &lt;el-input v-model=&quot;state.ruleForm.a21&quot; @input=&quot;onVerifyCarNum($event)&quot; placeholder=&quot;请输入车牌号进行测试&quot;&gt; &lt;/el-input&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/el-form-item&gt;</span><br><span class="line">            &lt;/el-form&gt;</span><br><span class="line">        &lt;/el-card&gt;</span><br><span class="line">    &lt;/div&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line"></span><br><span class="line">&lt;script setup lang=&quot;ts&quot; name=&quot;tools&quot;&gt;</span><br><span class="line">import &#123; reactive &#125; from &#x27;vue&#x27;;</span><br><span class="line">import &#123;</span><br><span class="line">    verifyNumberPercentage,</span><br><span class="line">    verifyNumberPercentageFloat,</span><br><span class="line">    verifyNumberIntegerAndFloat,</span><br><span class="line">    verifiyNumberInteger,</span><br><span class="line">    verifyCnAndSpace,</span><br><span class="line">    verifyEnAndSpace,</span><br><span class="line">    verifyAndSpace,</span><br><span class="line">    verifyNumberComma,</span><br><span class="line">    verifyTextColor,</span><br><span class="line">    verifyNumberCnUppercase,</span><br><span class="line">    verifyPhone,</span><br><span class="line">    verifyTelPhone,</span><br><span class="line">    verifyAccount,</span><br><span class="line">    verifyPassword,</span><br><span class="line">    verifyPasswordPowerful,</span><br><span class="line">    verifyPasswordStrength,</span><br><span class="line">    verifyIPAddress,</span><br><span class="line">    verifyEmail,</span><br><span class="line">    verifyIdCard,</span><br><span class="line">    verifyFullName,</span><br><span class="line">    verifyPostalCode,</span><br><span class="line">    verifyUrl,</span><br><span class="line">    verifyCarNum,</span><br><span class="line">&#125; from &#x27;/@/utils/toolsValidate&#x27;;</span><br><span class="line"></span><br><span class="line">// 定义变量内容</span><br><span class="line">const state = reactive(&#123;</span><br><span class="line">    text: &#x27;世间美好，与你环环相扣，祝你开心每一天！&#x27;,</span><br><span class="line">    phone: false,</span><br><span class="line">    cnText: &#x27;&#x27;,</span><br><span class="line">    telePhone: false,</span><br><span class="line">    account: false,</span><br><span class="line">    password: false,</span><br><span class="line">    passwordPowerful: false,</span><br><span class="line">    passwordStrength: &#x27;&#x27;,</span><br><span class="line">    iPAddress: false,</span><br><span class="line">    email: false,</span><br><span class="line">    idCard: false,</span><br><span class="line">    fullName: false,</span><br><span class="line">    postalCode: false,</span><br><span class="line">    url: false,</span><br><span class="line">    carNum: false,</span><br><span class="line">    /**</span><br><span class="line">     * 变量名为了方便，随便取了，</span><br><span class="line">     * 实际中，按正常程序进行命名</span><br><span class="line">     */</span><br><span class="line">    ruleForm: &#123;</span><br><span class="line">        a1: &#x27;&#x27;,</span><br><span class="line">        a2: &#x27;&#x27;,</span><br><span class="line">        a3: &#x27;&#x27;,</span><br><span class="line">        a4: &#x27;&#x27;,</span><br><span class="line">        a5: &#x27;&#x27;,</span><br><span class="line">        a6: &#x27;&#x27;,</span><br><span class="line">        a7: &#x27;&#x27;,</span><br><span class="line">        a8: &#x27;&#x27;,</span><br><span class="line">        a9: &#x27;&#x27;,</span><br><span class="line">        a10: &#x27;&#x27;,</span><br><span class="line">        a11: &#x27;&#x27;,</span><br><span class="line">        a12: &#x27;&#x27;,</span><br><span class="line">        a13: &#x27;&#x27;,</span><br><span class="line">        a14: &#x27;&#x27;,</span><br><span class="line">        a15: &#x27;&#x27;,</span><br><span class="line">        a16: &#x27;&#x27;,</span><br><span class="line">        a17: &#x27;&#x27;,</span><br><span class="line">        a18: &#x27;&#x27;,</span><br><span class="line">        a19: &#x27;&#x27;,</span><br><span class="line">        a20: &#x27;&#x27;,</span><br><span class="line">        a21: &#x27;&#x27;,</span><br><span class="line">        a22: &#x27;&#x27;,</span><br><span class="line">        a23: &#x27;&#x27;,</span><br><span class="line">    &#125;,</span><br><span class="line">    rules: &#123;</span><br><span class="line">        a1: [</span><br><span class="line">            &#123;</span><br><span class="line">                required: true,</span><br><span class="line">                message: &#x27;请输入小数或整数进行测试&#x27;,</span><br><span class="line">                trigger: &#x27;change&#x27;,</span><br><span class="line">            &#125;,</span><br><span class="line">        ],</span><br><span class="line">        a2: [</span><br><span class="line">            &#123;</span><br><span class="line">                required: true,</span><br><span class="line">                message: &#x27;请输入正整数进行测试&#x27;,</span><br><span class="line">                trigger: &#x27;change&#x27;,</span><br><span class="line">            &#125;,</span><br><span class="line">        ],</span><br><span class="line">        a3: [&#123; required: true, message: &#x27;请输入内容进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">        a4: [&#123; required: true, message: &#x27;请输入内容进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">        a5: [&#123; required: true, message: &#x27;请输入内容进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">        a6: [</span><br><span class="line">            &#123;</span><br><span class="line">                required: true,</span><br><span class="line">                message: &#x27;请输入小数或整数进行测试&#x27;,</span><br><span class="line">                trigger: &#x27;change&#x27;,</span><br><span class="line">            &#125;,</span><br><span class="line">        ],</span><br><span class="line">        a7: [&#123; required: true, message: &#x27;请输入内容进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">        a8: [&#123; required: true, message: &#x27;请输入金额进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">        a9: [</span><br><span class="line">            &#123;</span><br><span class="line">                required: true,</span><br><span class="line">                message: &#x27;请输入手机号进行测试&#x27;,</span><br><span class="line">                trigger: &#x27;change&#x27;,</span><br><span class="line">            &#125;,</span><br><span class="line">        ],</span><br><span class="line">        a10: [</span><br><span class="line">            &#123;</span><br><span class="line">                required: true,</span><br><span class="line">                message: &#x27;请输入国内电话号码进行测试&#x27;,</span><br><span class="line">                trigger: &#x27;change&#x27;,</span><br><span class="line">            &#125;,</span><br><span class="line">        ],</span><br><span class="line">        a11: [&#123; required: true, message: &#x27;请输入账号进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">        a12: [&#123; required: true, message: &#x27;请输入密码进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">        a13: [&#123; required: true, message: &#x27;请输入密码进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">        a14: [&#123; required: true, message: &#x27;请输入密码进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">        a15: [</span><br><span class="line">            &#123;</span><br><span class="line">                required: true,</span><br><span class="line">                message: &#x27;请输入IP地址进行测试&#x27;,</span><br><span class="line">                trigger: &#x27;change&#x27;,</span><br><span class="line">            &#125;,</span><br><span class="line">        ],</span><br><span class="line">        a16: [&#123; required: true, message: &#x27;请输入邮箱进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">        a17: [</span><br><span class="line">            &#123;</span><br><span class="line">                required: true,</span><br><span class="line">                message: &#x27;请输入身份证进行测试&#x27;,</span><br><span class="line">                trigger: &#x27;change&#x27;,</span><br><span class="line">            &#125;,</span><br><span class="line">        ],</span><br><span class="line">        a18: [&#123; required: true, message: &#x27;请输入姓名进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">        a19: [</span><br><span class="line">            &#123;</span><br><span class="line">                required: true,</span><br><span class="line">                message: &#x27;请输入邮政编码进行测试&#x27;,</span><br><span class="line">                trigger: &#x27;change&#x27;,</span><br><span class="line">            &#125;,</span><br><span class="line">        ],</span><br><span class="line">        a20: [&#123; required: true, message: &#x27;请输入内容进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">        a21: [</span><br><span class="line">            &#123;</span><br><span class="line">                required: true,</span><br><span class="line">                message: &#x27;请输入车牌号进行测试&#x27;,</span><br><span class="line">                trigger: &#x27;change&#x27;,</span><br><span class="line">            &#125;,</span><br><span class="line">        ],</span><br><span class="line">        a22: [&#123; required: true, message: &#x27;请输入数字进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">        a23: [&#123; required: true, message: &#x27;请输入数字进行测试&#x27;, trigger: &#x27;change&#x27; &#125;],</span><br><span class="line">    &#125;,</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line">// 验证百分比（不可以小数）</span><br><span class="line">const onVerifyNumberPercentage = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a22 = verifyNumberPercentage(val);</span><br><span class="line">&#125;;</span><br><span class="line">// 验证百分比（可以小数）</span><br><span class="line">const onVerifyNumberPercentageFloat = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a23 = verifyNumberPercentageFloat(val);</span><br><span class="line">&#125;;</span><br><span class="line">// 小数或整数</span><br><span class="line">const onVerifyNumberIntegerAndFloat = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a1 = verifyNumberIntegerAndFloat(val);</span><br><span class="line">&#125;;</span><br><span class="line">// 正整数</span><br><span class="line">const onVerifiyNumberInteger = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a2 = verifiyNumberInteger(val);</span><br><span class="line">&#125;;</span><br><span class="line">// 去掉中文及空格</span><br><span class="line">const onVerifyCnAndSpace = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a3 = verifyCnAndSpace(val);</span><br><span class="line">&#125;;</span><br><span class="line">// 去掉英文及空格</span><br><span class="line">const onVerifyEnAndSpace = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a4 = verifyEnAndSpace(val);</span><br><span class="line">&#125;;</span><br><span class="line">// 禁止输入空格</span><br><span class="line">const onVerifyAndSpace = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a5 = verifyAndSpace(val);</span><br><span class="line">&#125;;</span><br><span class="line">// 金额用 `,` 区分开</span><br><span class="line">const onVerifyNumberComma = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a6 = verifyNumberComma(val);</span><br><span class="line">&#125;;</span><br><span class="line">// 匹配文字变色（搜索时）</span><br><span class="line">const onVerifyTextColor = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a7 = verifyAndSpace(val);</span><br><span class="line">    if (state.ruleForm.a7 === &#x27;&#x27;) state.text = `世间美好，与你环环相扣，祝你开心每一天！`;</span><br><span class="line">    else state.text = verifyTextColor(state.ruleForm.a7, state.text);</span><br><span class="line">&#125;;</span><br><span class="line">// 数字转中文大写</span><br><span class="line">const onVerifyNumberCnUppercase = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a8 = verifyNumberIntegerAndFloat(val);</span><br><span class="line">    if (state.ruleForm.a8 === &#x27;&#x27;) state.cnText = &#x27;&#x27;;</span><br><span class="line">    else state.cnText = verifyNumberCnUppercase(state.ruleForm.a8);</span><br><span class="line">&#125;;</span><br><span class="line">// 手机号码</span><br><span class="line">const onVerifyPhone = (val: string) =&gt; &#123;</span><br><span class="line">    state.phone = verifyPhone(val);</span><br><span class="line">&#125;;</span><br><span class="line">// 国内电话号码</span><br><span class="line">const onVerifyTelPhone = (val: string) =&gt; &#123;</span><br><span class="line">    state.telePhone = verifyTelPhone(val);</span><br><span class="line">&#125;;</span><br><span class="line">// 登录账号</span><br><span class="line">const onVerifyAccount = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a11 = verifyCnAndSpace(val);</span><br><span class="line">    state.account = verifyAccount(state.ruleForm.a11);</span><br><span class="line">&#125;;</span><br><span class="line">// 密码</span><br><span class="line">const onVerifyPassword = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a12 = verifyCnAndSpace(val);</span><br><span class="line">    state.password = verifyPassword(state.ruleForm.a12);</span><br><span class="line">&#125;;</span><br><span class="line">// 强密码</span><br><span class="line">const onVerifyPasswordPowerful = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a13 = verifyCnAndSpace(val);</span><br><span class="line">    state.passwordPowerful = verifyPasswordPowerful(state.ruleForm.a13);</span><br><span class="line">&#125;;</span><br><span class="line">// 密码强度</span><br><span class="line">const onVerifyPasswordStrength = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a14 = verifyCnAndSpace(val);</span><br><span class="line">    state.passwordStrength = verifyPasswordStrength(state.ruleForm.a14);</span><br><span class="line">&#125;;</span><br><span class="line">// IP地址</span><br><span class="line">const onVerifyIPAddress = (val: string) =&gt; &#123;</span><br><span class="line">    state.iPAddress = verifyIPAddress(val);</span><br><span class="line">&#125;;</span><br><span class="line">// 邮箱</span><br><span class="line">const onVerifyEmail = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a16 = verifyCnAndSpace(val);</span><br><span class="line">    state.email = verifyEmail(state.ruleForm.a16);</span><br><span class="line">&#125;;</span><br><span class="line">// 身份证</span><br><span class="line">const onVerifyIDCard = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a17 = verifyCnAndSpace(val);</span><br><span class="line">    state.idCard = verifyIdCard(state.ruleForm.a17);</span><br><span class="line">&#125;;</span><br><span class="line">// 姓名</span><br><span class="line">const onVerifyFullName = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a18 = verifyAndSpace(val);</span><br><span class="line">    state.fullName = verifyFullName(state.ruleForm.a18);</span><br><span class="line">&#125;;</span><br><span class="line">// 邮政编码</span><br><span class="line">const onVerifyPostalCode = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a19 = verifiyNumberInteger(val);</span><br><span class="line">    state.postalCode = verifyPostalCode(state.ruleForm.a19);</span><br><span class="line">&#125;;</span><br><span class="line">// url</span><br><span class="line">const onVerifyUrl = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a20 = verifyAndSpace(val);</span><br><span class="line">    state.url = verifyUrl(state.ruleForm.a20);</span><br><span class="line">&#125;;</span><br><span class="line">// 车牌号</span><br><span class="line">const onVerifyCarNum = (val: string) =&gt; &#123;</span><br><span class="line">    state.ruleForm.a21 = verifyAndSpace(val);</span><br><span class="line">    state.carNum = verifyCarNum(state.ruleForm.a21);</span><br><span class="line">&#125;;</span><br><span class="line">&lt;/script&gt;</span><br><span class="line"></span><br><span class="line">&lt;style scoped lang=&quot;scss&quot;&gt;</span><br><span class="line">.tools-warp-form &#123;</span><br><span class="line">    :deep(.el-form-item--small.el-form-item) &#123;</span><br><span class="line">        margin-bottom: 0 !important;</span><br><span class="line">    &#125;</span><br><span class="line">    .tools-warp-form-msg &#123;</span><br><span class="line">        color: #666666;</span><br><span class="line">        font-size: 14px;</span><br><span class="line">        width: 100%;</span><br><span class="line">        .tools-warp-form-msg-red &#123;</span><br><span class="line">            color: red;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    .tools-warp-form-msg + div &#123;</span><br><span class="line">        width: 100%;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">&lt;/style&gt;</span><br></pre></td></tr></table></figure>
</article><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/web/">web</a><a class="post-meta__tags" href="/tags/%E5%89%8D%E7%AB%AF/">前端</a></div><div class="post_share"></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/blog/java/SpringBoot%20%E6%97%A5%E5%BF%97%E9%85%8D%E7%BD%AE/"><img class="prev-cover" src= "" data-lazy-src="/images/log.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">SpringBoot 日志配置</div></div></a></div><div class="next-post pull-right"><a href="/blog/utils/vue3%20%E6%8C%87%E4%BB%A4/"><img class="next-cover" src= "" data-lazy-src="/images/utils.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Vue3 指令</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/blog/utils/vue3 指令/" title="Vue3 指令"><img class="cover" src= "" data-lazy-src="/images/utils.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-01-18</div><div class="title">Vue3 指令</div></div></a></div><div><a href="/blog/utils/小程序base64转为本地文件（图片）/" title="小程序base64转为本地文件"><img class="cover" src= "" data-lazy-src="/images/utils.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-01-18</div><div class="title">小程序base64转为本地文件</div></div></a></div><div><a href="/blog/utils/时间格式化/" title="时间格式化"><img class="cover" src= "" data-lazy-src="/images/utils.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-01-18</div><div class="title">时间格式化</div></div></a></div><div><a href="/blog/utils/颜色工具 color/" title="颜色工具"><img class="cover" src= "" data-lazy-src="/images/utils.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-01-18</div><div class="title">颜色工具</div></div></a></div><div><a href="/blog/utils/获取浏览器默认语言/" title="获取浏览器默认语言"><img class="cover" src= "" data-lazy-src="/images/utils.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-01-18</div><div class="title">获取浏览器默认语言</div></div></a></div><div><a href="/blog/web/0 vue3项目创建手册/" title="Vue3 项目创建"><img class="cover" src= "" data-lazy-src="/images/vue.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-04-21</div><div class="title">Vue3 项目创建</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">一切解释权归本咸鱼所有</div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/blog/java/01%20Spring%20Security%20&amp;%20oauth2/" title="Spring Security &amp; Oauth2"><img src= "" data-lazy-src="/images/spring-security.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Spring Security &amp; Oauth2"/></a><div class="content"><a class="title" href="/blog/java/01%20Spring%20Security%20&amp;%20oauth2/" title="Spring Security &amp; Oauth2">Spring Security &amp; Oauth2</a><time datetime="2024-04-25T07:24:45.000Z" title="发表于 2024-04-25 15:24:45">2024-04-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/java/02%20JWT%E5%B7%A5%E5%85%B7%E7%B1%BB/" title="JWT工具类"><img src= "" data-lazy-src="/images/jwt.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="JWT工具类"/></a><div class="content"><a class="title" href="/blog/java/02%20JWT%E5%B7%A5%E5%85%B7%E7%B1%BB/" title="JWT工具类">JWT工具类</a><time datetime="2024-04-25T07:24:45.000Z" title="发表于 2024-04-25 15:24:45">2024-04-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/java/00%20Security%20%E9%9B%86%E6%88%90%E7%A4%BA%E4%BE%8B/" title="SpringSecurity 集成示例"><img src= "" data-lazy-src="/images/spring-security.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="SpringSecurity 集成示例"/></a><div class="content"><a class="title" href="/blog/java/00%20Security%20%E9%9B%86%E6%88%90%E7%A4%BA%E4%BE%8B/" title="SpringSecurity 集成示例">SpringSecurity 集成示例</a><time datetime="2024-04-25T07:24:43.000Z" title="发表于 2024-04-25 15:24:43">2024-04-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/java/101%20Mybatis-plus%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90/" title="MybatisPlus 快速集成"><img src= "" data-lazy-src="/images/mybatis-plus.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="MybatisPlus 快速集成"/></a><div class="content"><a class="title" href="/blog/java/101%20Mybatis-plus%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90/" title="MybatisPlus 快速集成">MybatisPlus 快速集成</a><time datetime="2024-04-21T07:39:43.000Z" title="发表于 2024-04-21 15:39:43">2024-04-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/java/10%20Mybatis%20%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90/" title="Mybatis 快速集成"><img src= "" data-lazy-src="/images/mybaits.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Mybatis 快速集成"/></a><div class="content"><a class="title" href="/blog/java/10%20Mybatis%20%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90/" title="Mybatis 快速集成">Mybatis 快速集成</a><time datetime="2024-04-21T07:24:43.000Z" title="发表于 2024-04-21 15:24:43">2024-04-21</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2024 By mowei</div><div class="footer_custom_text">海内存知已，天涯若比邻</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>if (document.getElementsByClassName('mermaid').length) {
  if (window.mermaidJsLoad) mermaid.init()
  else {
    getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(() => {
      window.mermaidJsLoad = true
      mermaid.initialize({
        theme: 'default',
      })
      true && mermaid.init()
    })
  }
}</script></div><div class="aplayer no-destroy" data-id="9385310356" data-server="netease" data-type="playlist" data-fixed="true" data-mini="true" data-listFolded="false" data-order="random" data-preload="none" data-autoplay="true" muted></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = [
  'title',
  '#config-diff',
  '#body-wrap',
  '#rightside-config-hide',
  '#rightside-config-show',
  '.js-pjax'
]

if (false) {
  pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
}

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.removeEventListener('scroll', window.tocScrollFn)
  window.removeEventListener('scroll', scrollCollect)

  typeof preloader === 'object' && preloader.initLoading()
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // Analytics
  if (false) {
    MtaH5.pgv()
  }

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script src="/live2d_models/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2d_models/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2d_models/assets/wanko.model.json"},"display":{"position":"left","width":100,"height":150,"hOffset":-10,"vOffset":40},"mobile":{"show":true},"react":{"opacity":0.7},"log":false});</script></body></html>